import App from './App'

// 工具
import utils from '@/utils/utils';
import config from '@/config';

// #ifndef VUE3
import Vue from 'vue'
// 依赖
import uView from '@/uni_modules/uview-ui'
Vue.use(uView)

Vue.config.productionTip = false
App.mpType = 'app'
import '@/api'; // 引入自定义的 API 插件
// 全局
Object.assign(Vue.prototype, utils);
Object.assign(Vue.prototype, config);
Vue.prototype.getWinTop = () => {
	return new Promise((resolve, reject) => {
		uni.getSystemInfo({
			success: (e, any) => {
				let statusBar = 0;
				let customBar = 0;
				let navbar = 0;


				// #ifdef MP
				statusBar = e.statusBarHeight;
				customBar = e.statusBarHeight + 45;
				if (e.platform === 'android') {
					customBar = e.statusBarHeight + 50;
				}
				// #endif


				// #ifdef MP-WEIXIN
				statusBar = e.statusBarHeight;
				const custom = wx.getMenuButtonBoundingClientRect();
				customBar = custom.bottom + custom.top - e.statusBarHeight;

				navbar = (custom.top - e.statusBarHeight) * 2 + custom.height;
				// #endif


				// #ifdef MP-ALIPAY
				statusBar = e.statusBarHeight;
				customBar = e.statusBarHeight + e.titleBarHeight;
				// #endif


				// #ifdef APP-PLUS
				statusBar = e.statusBarHeight;
				customBar = e.statusBarHeight + 45;
				// #endif


				// #ifdef H5
				statusBar = 0;
				customBar = e.statusBarHeight + 45;
				// #endif

				resolve({
					statusBar
					, customBar
					, navbar
				});
		 
			}
		});
	});
};


const app = new Vue({
    ...App
})

app.$mount()
// #endif


//************************************************************

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif